package com.itheima.service.db.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.domain.db.QuestionText;
import com.itheima.mapper.QuestionTextMapper;
import com.itheima.service.db.QuestionTextService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class QuestionTextServiceImpl implements QuestionTextService {

    @Autowired
    QuestionTextMapper questionTextMapper;

    /**
     * 根据类型id查询问题集合
     * @param typeId
     * @return
     */
    @Override
    public List<QuestionText> findByTypeId(Integer typeId) {
        //1.创建查询条件根据等级类型id
        LambdaQueryWrapper<QuestionText> qw = new LambdaQueryWrapper<>();
        qw.eq(QuestionText::getTypeId,typeId);
        qw.orderByAsc(QuestionText::getSort);
        //2.查询数据库
        List<QuestionText> questionTexts = questionTextMapper.selectList(qw);
        return questionTexts;
    }

    @Override
    public QuestionText findById(String questionId) {
        return questionTextMapper.selectById(questionId);
    }
}
